interface Person {
  uname: string;
  age: number;
}
interface Son extends Person {}

class Person {}
class son extends Person implements Person {}

// 接口可以继承接口  接口不能实现接口
// 类可以继承类 类可以实现接口

const person: Person = {
  uname: "",
  age: 18,
  // height:1.88  //报错
};

const obj = {
  uname: "",
  age: 18,
  height: 1.88, //不报错
};
const info: Person = obj;

//索引签名
interface ICollection {
  [index: number]: string;
  length: number;
}
const array: ICollection = [];
function printCollection(colletion: ICollection) {
  for (const key in colletion) {
    if (Object.prototype.hasOwnProperty.call(colletion, key)) {
      const element = colletion[key];
    }
  }
}
printCollection(["1", "", "32"]);
printCollection(array);

interface IIndexType {
  [index: number]: string;
  // [index: string]: any;
  // [index: string]: any;
}
// names[0] => names['0'] 一样

const names: IIndexType = ["ss", "22d", "我的我的"]; //报错
// names['foreach'] =>function
// names["forEach"](() => {});

//一般处理 加两条
interface IIndexType2 {
  [index: number]: string; //先写number
  [index: string]: any;
  // [index: string]: any;
}
// names[0] => names['0'] 一样

const names2: IIndexType2 = ["ss", "22d", "我的我的"]; //报错
// names['foreach'] =>function
// names["forEach"](() => {});
const names3: IIndexType2 = ["a", "d", "d"];

interface person {
  uname: string;
  age: number;
}

class son2 implements person {
  uname = "12";
  age = 18;
}

//抽象类和接口的区别
//抽象类 捕捉子类的通用特新 接口通常是一些行为的描述
//接口可以多实现 抽象类只能单一继承
// 接口做通用的行为规范 不关心父子关系
